<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改菜单</title>
    <link href="${request.contextPath}/static/css/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link href="${request.contextPath}/static/fonts/font-awesome.css" rel="stylesheet">
    <link href="${request.contextPath}/static/css/animate.css" rel="stylesheet" type="text/css">
    <link href="${request.contextPath}/static/css/jdGrid/ui.jqgrid.css" rel="stylesheet" type="text/css"/>
    <link href="${request.contextPath}/static/css/style.css" rel="stylesheet">
    <link href="${request.contextPath}/static/ajax/libs/iCheck/custom.css" rel="stylesheet">
    <script type="text/javascript">
        var ctx = "";
        var __cityId = "";
    </script>
</head>
<body class="gray-bg">
<div class="wrapper">
    <div class="row">
        <div class="ibox">
            <div class="ibox-content">
                <form  class="form-horizontal" id="defaultForm"  method="post" onsubmit="return false;">
                    <input id="parentId" name="parentId" class="form-control" type="hidden" value="${menu1.parentId}"/>
                    <input id="menuId" name="menuId" class="form-control" type="hidden" value="${menu1.menuId?c}"/>
                    <div class="form-group"><label class="col-sm-2 control-label">上级菜单</label>
                        <div class="col-sm-10">
                            <div class="input-group">
                                <#if menu2??>
                                    <input id="menuName" name="parent.name" readonly="readonly" type="text" value="${menu2.menuName}"
                                           class="form-control required">
                                <#else>
                                    <input id="menuName" name="parent.name" readonly="readonly" type="text" value="默认一级菜单"
                                           class="form-control required">
                                </#if>
                                <span class="input-group-btn">
                                 <button type="button" id="menuButton" class="btn   btn-primary"><i
                                             class="fa fa-search"></i></button>
                             </span>
                            </div>
                        </div>
                    </div>


                    <div class="form-group">
                        <label class="col-sm-2 control-label"><font color="red">*</font>名称</label>
                        <div class="col-sm-10">
                            <input id="name" name="menuName" class="required form-control" type="text" value="${menu1.menuName}" maxlength="50" >
                        </div>
                    </div>



                    <div class="form-group"><label class="col-sm-2 control-label">链接</label>

                        <div class="col-sm-10">
                            <input id="url" name="url" class="form-control " type="text" value="${menu1.url}"
                                   maxlength="2000">
                            <span class="help-block m-b-none">点击菜单跳转的页面</span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">图标</label>

                        <div class="col-sm-10">
                            <input id="icon" name="icon" class="form-control " type="text" value="${menu1.icon}">
                            <span class="help-block m-b-none">参考Font Awesome 4.7.0</span>

                        </div>
                    </div>



                    <div class="form-group">
                        <label class="col-sm-2 control-label"><font color="red">*</font>排序</label>

                        <div class="col-sm-10">
                            <input id="orderNum" name="orderNum" class="required digits form-control " type="text" value="${menu1.orderNum}"
                                   maxlength="50"/>
                            <span class="help-block m-b-none">排列顺序，升序</span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">权限标识</label>
                        <div class="col-sm-10"><input id="perms" name="perms" class="form-control " type="text" value="${menu1.perms}" maxlength="100">
                            <span class="help-block m-b-none">控制器中定义的权限标识，如@RequiresPermissions("权限标识")</span>
                        </div>

                    </div>


                    <div class="form-group">
                        <label class="col-sm-2 control-label">备注</label>
                        <div class="col-sm-10">
                            <textarea id="remark" name="remark" maxlength="200" class="form-control" rows="3">${menu1.remark}</textarea>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-sm-6">
                            <div class="form-group" style=" padding-left: 550px;padding-top: 40px;">
                                <button type="button" class="btn btn-primary" id="enter" >确定</button>
                                <button type="button" class="btn btn-default" id="cancel">取消</button>
                            </div>
                        </div>
                    </div>


                </form>
            </div>
        </div>
    </div>
</div>
</body>
<script src="${request.contextPath}/static/js/jquery.min.js"></script>
<script src="${request.contextPath}/static/js/bootstrap.min.js"></script>
<script src="${request.contextPath}/static/js/layer/layer.min.js"></script>
<script src="${request.contextPath}/static/js/tookeen.js"></script>
<script src="${request.contextPath}/static/js/common.js"></script>
<script src="${request.contextPath}/static/js/contabs-v2.js" type="text/javascript"></script>
<script src="${request.contextPath}/static/ajax/libs/iCheck/icheck.min.js"></script>
<script src="${request.contextPath}/static/js/validate/jquery.validate.min.js"></script>
<script src="${request.contextPath}/static/plugins/validate/messages_zh.min.js"></script>
<script src="${request.contextPath}/static/js/jquery.form.min.js" type="text/javascript"></script>
<script>

    $("#menuButton, #menuName").click(function(){
        var id = $("#menuId").val();
        // // 是否限制选择，如果限制，设置为disabled
        if ($("#menuButton").hasClass("disabled")){
            return true;
        }
        // 正常打开
        layer.open({
            type: 2,
            area: ['300px', '420px'],
            title:"选择菜单",
            content: "${request.contextPath}/menuManage/tree",
        });
    });

    $("#enter").click(function () {
        var menuId = $("#menuId").val();
        var parentId = $("#parentId").val();
        var name = $("#name").val();
        var url = $("#url").val();
        var icon = $("#icon").val();
        var orderNum = $("#orderNum").val();
        var perms = $("#perms").val();
        var remark = $("#remark").val();

        $.ajax({
            url:"${request.contextPath}/menuManage/update",
            type:"get",
            data:{menuId:menuId,menuName:name,parentId:parentId,url:url,icon:icon,orderNum:orderNum,perms:perms,remark:remark},
            success:function (data) {
                if (data.code!=null || data.code!=''){
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.$("#hi1").val("1");
                    parent.layer.close(index);//关闭当前页
                }
            } ,
            error:function (){
            }
        });



    });

    $("#cancel").on('click',function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);//关闭当前页
    });




    // var validateForm;
    // var  doSubmit = function(){
    //     if(validateForm.form()) {
    //         var index = parent.layer.getFrameIndex(window.name);
    //         $("#defaultForm").ajaxSubmit(function (result) {
    //             if (result.code  == 0) {
    //                 var callback = share.remove(index);
    //                 if (callback && typeof(callback) === "function") {
    //                     callback();
    //                 }
    //                 parent.layer.msg('操作成功', {icon: 1});
    //                 parent.layer.close(index);
    //
    //
    //             } else if (result.code == 500) {
    //                 parent.layer.alert(result.message, {
    //                     icon: 2
    //                 })
    //             } else {
    //                 parent.layer.close(index);
    //             }
    //         });
    //
    //     }
    //     return false;
    // };
    //
    // $(document).ready(function() {
    //
    //     $('.i-checks').iCheck({
    //         checkboxClass: 'icheckbox_square-green',
    //         radioClass: 'iradio_square-green',
    //     });
    //
    //     $("#name").focus();
    //     validateForm = $("#defaultForm").validate({
    //         submitHandler: function(form){
    //             doSubmit();
    //         },
    //         errorPlacement: function(error, element) {
    //             if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
    //                 error.appendTo(element.parent().parent().parent());
    //             } else {
    //                 error.insertAfter(element);
    //             }
    //         }
    //     });
    // });
</script>
</html>